package com.ay277.htqoa.base.controller;


import com.ay277.htqoa.base.biz.UserBiz;
import com.ay277.htqoa.base.biz.UserBizImpl;
import com.ay277.htqoa.base.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Salery on 2016/12/9.
 */
@Controller
public class UserController {
    private UserBiz userBiz=new UserBizImpl();
    private User user;
    @RequestMapping("/saveUser")
    public String saveUser(){
        userBiz.doSave(user);
    return "firstPage";
    }
    @RequestMapping("/goLogin")
    public String goLogin(){
        return "login";
    }
    @RequestMapping("/login")
    public String login(String userName,String pwd, ModelMap modelMap){
        //user=userBiz.exist(userName,pwd);
        if(user!=null){
            modelMap.addAttribute("user",user);
        }
        return "firstPage";
    }
    @RequestMapping("/findAll")
    public List<User> findAll(){
      List<User> users= userBiz.findAll();
        System.out.println(users.size());
        return users;
    }



    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
